# test menus
use strict;

=pod

This will put several entries in the menu; select them from there to test them

=cut

{
	package PlPN::MenuItem;
	use strict;

	sub real_menu_handler {
		my ($item, $cookie, $type) = @_;
		my $info = join("\n\t", map { "$_ => $item->{$_}" } sort keys %$item);
		PlPN->alert(<<INFO);
Type: $type
Cookie: $cookie
Item: $item
	$info
INFO
	}

	sub subname_menu_handler {
		real_menu_handler(@_, 'subname');
	}

	sub coderef_menu_handler {
		real_menu_handler(@_, 'coderef');
	}

	sub method_menu_handler {
		real_menu_handler(@_, 'method');
	}

	our $item = bless {
		text => 'Level 1',
		id => "lvl1",
		submenu => new PlPN::Menu("sbm1", [
			{
				text => 'Level 2',
				id => "lvl2",
				submenu => new PlPN::Menu("sbm2", [
					{
						text => 'Subname',
						id => "sbnm",
						handler => 'PlPN::MenuItem::subname_menu_handler',
						#handler => \&coderef_menu_handler,
						#method => 'method_menu_handler',
					},
					{
						text => 'Coderef',
						id => "cdrf",
						#handler => 'PlPN::MenuItem::subname_menu_handler',
						handler => \&coderef_menu_handler,
						#method => 'method_menu_handler',
					},
					bless({
						text => 'Method',
						id => "mthd",
						#handler => 'PlPN::MenuItem::subname_menu_handler',
						#handler => \&coderef_menu_handler,
						method => 'method_menu_handler',
					}, __PACKAGE__),
				]),
			},
		]),
	}, __PACKAGE__;
}

use PlPN qw(PN);

my $menu = new PlPN::Menu("menu", [ {  text => '-', id => 1 }, $PlPN::MenuItem::item ]);

PN->AddPluginMenuItems($menu);
